package domain.entities;

import javax.persistence.*;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * ContactPerson entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "contact_person", catalog = "bms")
public class ContactPerson implements java.io.Serializable {

	// Fields

	private Integer id;
	private Degree degree;
    private String otherDegree;
	private String email;
	private String fax;
	private String horarioAtencion;
	private String phone;
    private ComiteEtica comiteEtica;
    private ComiteDocencia comiteDocencia;
    private String name;
    private String surname;
    private String hours;
    private String timeEnvelopes;

    private RoleInCommittee roleInCommittee;
    private String otherRoleInCommittee;
	// Constructors

	/** default constructor */
	public ContactPerson() {
	}

	/** full constructor */
	public ContactPerson(String degree,
			String email, String fax, String horarioAtencion, String phone,
            ComiteEtica comiteEtica,ComiteDocencia comiteDocencia) {
		this.email = email;
		this.fax = fax;
		this.horarioAtencion = horarioAtencion;
		this.phone = phone;
        this.comiteEtica = comiteEtica;
	}

    public enum RoleInCommittee{
        _Chairman(0,"Chairman"),
        _Member(1,"Member"),
        _Secretary(2,"Secretary"),
        Other(3,"Other");

        private String desc;
        private Integer id;

        RoleInCommittee(){
            this.id = -1;
            this.desc = "";
        }

        RoleInCommittee(Integer id,String name){
            this.id = id;
            this.desc = name;
        }

        public String getDescription(){
            return this.desc;
        }

        public Integer getId() {
            return this.id;
        }

        public void setName(String name) {
            this.desc = name;
        }

        public void setId(Integer id) {
            this.id = id;
        }
    }

    public enum Degree{
        _MD(0,"MD"),
        _Ph(1,"Ph"),
        _Lic(2,"Lic"),
        Other(3,"Other");

        private String desc;
        private Integer id;

        Degree(){
            this.id = -1;
            this.desc = "";
        }

        Degree(Integer id,String name){
            this.id = id;
            this.desc = name;
        }

        public String getDescription(){
            return this.desc;
        }

        public Integer getId() {
            return this.id;
        }

        public void setName(String name) {
            this.desc = name;
        }

        public void setId(Integer id) {
            this.id = id;
        }
    }

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "email")
	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Column(name = "fax")
	public String getFax() {
		return this.fax;
	}

	public void setFax(String fax) {
		this.fax = fax;
	}

	@Column(name = "horarioAtencion")
	public String getHorarioAtencion() {
		return this.horarioAtencion;
	}

	public void setHorarioAtencion(String horarioAtencion) {
		this.horarioAtencion = horarioAtencion;
	}

	@Column(name = "phone")
	public String getPhone() {
		return this.phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}
    @Column(name = "name")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "surname")
    public String getSurname() {
        return surname;
    }

    public void setSurname(String surname) {
        this.surname = surname;
    }

    @ManyToOne(cascade = {CascadeType.MERGE, CascadeType.DETACH, CascadeType.PERSIST, CascadeType.REFRESH}, optional = true)
    public ComiteEtica getComiteEtica() {
        return comiteEtica;
    }

    public void setComiteEtica(ComiteEtica comiteEtica) {
        this.comiteEtica = comiteEtica;
    }

    @ManyToOne(cascade = {CascadeType.MERGE, CascadeType.DETACH, CascadeType.PERSIST, CascadeType.REFRESH}, optional = true)
    public ComiteDocencia getComiteDocencia() {
        return comiteDocencia;
    }

    public void setComiteDocencia(ComiteDocencia comiteDocencia) {
        this.comiteDocencia = comiteDocencia;
    }

    public String getHours() {
        return hours;
    }

    public void setHours(String hours) {
        this.hours = hours;
    }


    @Column(name = "time_envelopes")
    public String getTimeEnvelopes() {
        return this.timeEnvelopes;
    }

    public void setTimeEnvelopes(String timeEnvelopes) {
        this.timeEnvelopes = timeEnvelopes;
    }


    @Enumerated(EnumType.ORDINAL)
    public RoleInCommittee getRoleInCommittee() {
        return roleInCommittee;
    }

    public void setRoleInCommittee(RoleInCommittee roleInCommittee) {
        this.roleInCommittee = roleInCommittee;
    }

    public void setRoleInCommittee(String id){
        RoleInCommittee t = RoleInCommittee.values()[Integer.parseInt(id)];
        this.setRoleInCommittee(t);
    }

    @Column(name = "otherRoleInCommittee")
    public String getOtherRoleInCommittee(){
        return otherRoleInCommittee;
    }

    public void setOtherRoleInCommittee(String otherRoleInCommittee){
        this.otherRoleInCommittee = otherRoleInCommittee;
    }


    @Enumerated(EnumType.ORDINAL)
    public Degree getDegree() {
        return degree;
    }

    public void setDegree(Degree degree) {
        this.degree = degree;
    }

    public void setDegree(String id){
        Degree t = Degree.values()[Integer.parseInt(id)];
        this.setDegree(t);
    }

    @Column(name = "otherDegree")
    public String getOtherDegree(){
        return otherDegree;
    }

    public void setOtherDegree(String otherDegree){
        this.otherDegree = otherDegree;
    }
}